package com.teemor.im.remoting.netty;

import com.teemor.im.common.model.ImMessage;
import com.teemor.im.remoting.storage.Storage;
import com.teemor.im.remoting.storage.StorageModel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @ename zhoulk
 * @cname 周李科
 * @date 2020/6/12 16:27
 */
public class MessageStorageHandler extends SimpleChannelInboundHandler<ImMessage> {

    private Storage<ImMessage> storage;

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, ImMessage message) throws Exception {
        storage.storage(new StorageModel<>(message));
        channelHandlerContext.fireChannelRead(message);
    }
}
